package com.library.utils
{
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	public class TextFieldUtil
	{
		public function TextFieldUtil(){}
		
		public static function Generate(	text:String,
											size:int,
											color:uint,
											font:String,
											selectAble:Boolean = false,
											embeded:Boolean = true,
											multiline:Boolean = false,
											align:String = TextFormatAlign.LEFT,
											autoSize:String = TextFieldAutoSize.LEFT,
											wordWrap:Boolean = false):TextField
		{
			var tfm:TextFormat = new TextFormat(font, size, color);
			tfm.align = align;
			
			var txtField:TextField = new TextField();
			txtField.defaultTextFormat = tfm;
			txtField.selectable = selectAble;
			txtField.embedFonts = embeded;
			if(autoSize != "") txtField.autoSize = autoSize;
			txtField.multiline = multiline;
			txtField.wordWrap = wordWrap;
			
			txtField.text = text;
			
			return txtField;
		}
		
		public static function GenerateWithTFM(	text:String,
											tfm:TextFormat,
											selectAble:Boolean = false,
											embeded:Boolean = true,
											multiline:Boolean = false,
											autoSize:String = TextFieldAutoSize.LEFT,
											wordWrap:Boolean = false):TextField
		{
			var txtField:TextField = new TextField();
			txtField.defaultTextFormat = tfm;
			txtField.selectable = selectAble;
			txtField.embedFonts = embeded;
			txtField.autoSize = autoSize;
			txtField.multiline = multiline;
			txtField.wordWrap = wordWrap;
			
			return txtField;
		}
		
	}
}